package com.xu.serviceconsumer.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class SleuthController {

    private static final Logger LOG = LoggerFactory.getLogger(SleuthController.class);

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/hi")
    public String callHome() {
        LOG.info("calling trace service-hi  ");
        return restTemplate.getForObject("http://localhost:8767/info", String.class);
    }

    @RequestMapping("/info")
    public String info() {
        LOG.info("calling trace service-sleuth-8768 ");
        return "i'm ervice-sleuth-8768";

    }

}
